package com.zks.example.拆包粘包;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

public class MyClient {

    public static void main(String[] args) {
        Socket clientSocket = new Socket();
        try {
            clientSocket.setSendBufferSize(10);
            clientSocket.connect(new InetSocketAddress(8089));

            String reqMessage = "HelloWorld！ from clientsocket this is test half packages! ";
            OutputStream os = clientSocket.getOutputStream();

            for (int i = 0; i < 5000; i++) {
                os.write(reqMessage.getBytes());
                System.out.println("send message " + i + " " + reqMessage);
            }
            os.flush();
            while (true){

            }

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (clientSocket != null) {
                try {
                    clientSocket.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

        }
    }
}
